package com.xaicode.template.webflux.router;

import com.xaicode.template.webflux.handler.CityHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 * @author Locker
 * @date 2021/8/4 0004 17:10
 */
@Configuration
public class CityRouter {

    @Bean
    public RouterFunction<ServerResponse> routerCity(CityHandler cityHandler) {
        return RouterFunctions
                .route(
                        RequestPredicates
                                .GET("/city1")
                                .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
                        cityHandler::city1
                );
    }

}
